<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浮动-父子关系</title>
    <style>
        /*方法二： after伪元素清除浮动 */
        /* .clearfix::after{
            content: '.';
            display: block;
            height: 0;
            clear: both;
            visibility: hidden;
        } */
        .f{
            width: 300px;
            /* height: 200px; */
            border-top: 3px solid orange;
        }
        .s1{
            width: 100px;
            height: 100px;
            background-color: black;
             /* 设置为浮动时，块级元素将转换成inline-block */
            float:left;
        }
        .s2{
            width: 100px;
            height: 300px;
            background-color:yellow;
            /* 设置为浮动时，行级元素将转换成inline-block */
            float:left;
            
        }
        .other{
            width:300px;
            height: 300px;
            background-color: chartreuse;
            /*方法一：清除上方浮动  */
            /* clear: both; */
        }
    </style>
</head>
<body>
    <div class="f clearfix">
        <div class="s1"></div>
        <span class="s2"></span>
    </div>
    <div class="other"></div>
</body>
</html>